//
//  Qiangbao_tixianViewController.m
//  tianjin
//
//  Created by 鞠超 on 16/8/11.
//  Copyright © 2016年 jc. All rights reserved.
//

#import "Qiangbao_tixianViewController.h"

@interface Qiangbao_tixianViewController () <UIScrollViewDelegate, UITextFieldDelegate>

@property (nonatomic, strong) UIScrollView * scrollView;
//
@property (nonatomic, strong) UITextField * text_zhifubao;
@property (nonatomic, strong) UITextField * text_userName;

//
@property (nonatomic, strong) UIButton * btn_5;
@property (nonatomic, strong) UIButton * btn_10;
@property (nonatomic, strong) UIButton * btn_20;
@property (nonatomic, strong) UIButton * btn_50;
@property (nonatomic, strong) UIButton * btn_100;
@property (nonatomic, strong) UIButton * btn_200;
@property (nonatomic, strong) UIButton * btn_500;
@property (nonatomic, strong) UIButton * btn_1000;

@property (nonatomic, strong) UILabel * lbl_yue;

@end

@implementation Qiangbao_tixianViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self p_navi];
    
    [self p_setupView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navi
- (void)p_navi
{
    _btnLeft.hidden = YES;
    _lblLeft.hidden = YES;
    _btnRight.hidden = YES;
    _lblRight.hidden = YES;
    _topView.backgroundColor = [UIColor blackColor];
    
    _lblTitle.text = @"提现";
    _lblTitle.textColor = [UIColor whiteColor];
    _lblTitle.font = [UIFont systemFontOfSize:19];
    
    UIImageView * image_return = [[UIImageView alloc] initWithFrame:CGRectMake(15, 32, 10, 20)];
    image_return.image = [UIImage imageNamed:@"zuofanhui@2x.png"];
    [_topView addSubview:image_return];
    
    UIButton * btn_return = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_return.frame = CGRectMake(10, 20, 35, 44);
    [_topView addSubview:btn_return];
    [btn_return addTarget:self action:@selector(btn_returnAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

//左返回
- (void )btn_returnAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

//显示tabbar
- (void )viewWillAppear:(BOOL)animated
{
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] hiddenTabBar];
}

#pragma mark - 布局
- (void )p_setupView
{
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64)];
    self.scrollView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.scrollView.contentSize = CGSizeMake(0, SCREEN_HEIGHT - 60);
    self.scrollView.showsVerticalScrollIndicator = NO;
    self.scrollView.delegate = self;
    [self.view addSubview:self.scrollView];
    
    
    //支付宝账号
    UIView * view_1 = [[UIView alloc] initWithFrame:CGRectMake(15, 17, SCREEN_WIDTH - 30, 50)];
    view_1.backgroundColor = [UIColor whiteColor];
    view_1.layer.cornerRadius = 5;
    view_1.layer.borderColor = [UIColor grayColor].CGColor;
    view_1.layer.borderWidth = 0.5f;
    [self.scrollView addSubview:view_1];
    
    self.text_zhifubao = [[UITextField alloc] initWithFrame:CGRectMake(15, 5, view_1.frame.size.width - 25, 40)];
    self.text_zhifubao.placeholder = @"请输入支付宝账号";
    self.text_zhifubao.returnKeyType = UIReturnKeyDone;
    self.text_zhifubao.font = [UIFont systemFontOfSize:15];
    self.text_zhifubao.clearButtonMode = UITextFieldViewModeAlways;
    self.text_zhifubao.delegate = self;
    [view_1 addSubview:self.text_zhifubao];
    
    //姓名
    UIView * view_2 = [[UIView alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(view_1.frame) + 12, SCREEN_WIDTH - 30, 50)];
    view_2.backgroundColor = [UIColor whiteColor];
    view_2.layer.cornerRadius = 5;
    view_2.layer.borderColor = [UIColor grayColor].CGColor;
    view_2.layer.borderWidth = 0.5f;
    [self.scrollView addSubview:view_2];
    
    self.text_userName = [[UITextField alloc] initWithFrame:CGRectMake(15, 5, view_2.frame.size.width - 25, 40)];
    self.text_userName.placeholder = @"请输入收款人姓名";
    self.text_userName.returnKeyType = UIReturnKeyDone;
    self.text_userName.font = [UIFont systemFontOfSize:15];
    self.text_userName.clearButtonMode = UITextFieldViewModeAlways;
    self.text_userName.delegate = self;
    [view_2 addSubview:self.text_userName];
    
    
    //
    CGFloat length_x = (SCREEN_WIDTH - 60) / 3;
    
    //5
    self.btn_5 = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.btn_5.frame = CGRectMake(15 , CGRectGetMaxY(view_2.frame) + 12, length_x, 45);
    self.btn_5.tag = 5;
    self.btn_5.layer.cornerRadius = 5;
    self.btn_5.layer.borderColor = [UIColor grayColor].CGColor;
    self.btn_5.layer.borderWidth = 0.5f;
    self.btn_5.backgroundColor = [UIColor whiteColor];
    [self.btn_5 setTitle:@"5元" forState:(UIControlStateNormal)];
    [self.btn_5 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    [self.scrollView addSubview:self.btn_5];
    [self.btn_5 addTarget:self action:@selector(btn_tixian:) forControlEvents:(UIControlEventTouchUpInside)];
    
    
    //10
    self.btn_10 = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.btn_10.frame = CGRectMake(CGRectGetMaxX(self.btn_5.frame) + 15, CGRectGetMaxY(view_2.frame) + 12, length_x, 45);
    self.btn_10.tag = 10;
    self.btn_10.layer.cornerRadius = 5;
    self.btn_10.layer.borderColor = [UIColor grayColor].CGColor;
    self.btn_10.layer.borderWidth = 0.5f;
    self.btn_10.backgroundColor = [UIColor whiteColor];
    [self.btn_10 setTitle:@"10元" forState:(UIControlStateNormal)];
    [self.btn_10 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    [self.scrollView addSubview:self.btn_10];
    [self.btn_10 addTarget:self action:@selector(btn_tixian:) forControlEvents:(UIControlEventTouchUpInside)];
    
    
    //20
    self.btn_20 = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.btn_20.frame = CGRectMake(CGRectGetMaxX(self.btn_10.frame) + 15, CGRectGetMaxY(view_2.frame) + 12, length_x, 45);
    self.btn_20.tag = 20;
    self.btn_20.layer.cornerRadius = 5;
    self.btn_20.layer.borderColor = [UIColor grayColor].CGColor;
    self.btn_20.layer.borderWidth = 0.5f;
    self.btn_20.backgroundColor = [UIColor whiteColor];
    [self.btn_20 setTitle:@"20元" forState:(UIControlStateNormal)];
    [self.btn_20 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    [self.scrollView addSubview:self.btn_20];
    [self.btn_20 addTarget:self action:@selector(btn_tixian:) forControlEvents:(UIControlEventTouchUpInside)];
    
    
    //50
    self.btn_50 = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.btn_50.frame = CGRectMake(15 , CGRectGetMaxY(self.btn_5.frame) + 12, length_x, 45);
    self.btn_50.tag = 50;
    self.btn_50.layer.cornerRadius = 5;
    self.btn_50.layer.borderColor = [UIColor grayColor].CGColor;
    self.btn_50.layer.borderWidth = 0.5f;
    self.btn_50.backgroundColor = [UIColor whiteColor];
    [self.btn_50 setTitle:@"50元" forState:(UIControlStateNormal)];
    [self.btn_50 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    [self.scrollView addSubview:self.btn_50];
    [self.btn_50 addTarget:self action:@selector(btn_tixian:) forControlEvents:(UIControlEventTouchUpInside)];
    
    
    //100
    self.btn_100 = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.btn_100.frame = CGRectMake(CGRectGetMaxX(self.btn_50.frame) + 15, CGRectGetMaxY(self.btn_5.frame) + 12, length_x, 45);
    self.btn_100.tag = 100;
    self.btn_100.layer.cornerRadius = 5;
    self.btn_100.layer.borderColor = [UIColor grayColor].CGColor;
    self.btn_100.layer.borderWidth = 0.5f;
    self.btn_100.backgroundColor = [UIColor whiteColor];
    [self.btn_100 setTitle:@"100元" forState:(UIControlStateNormal)];
    [self.btn_100 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    [self.scrollView addSubview:self.btn_100];
    [self.btn_100 addTarget:self action:@selector(btn_tixian:) forControlEvents:(UIControlEventTouchUpInside)];
    
    
    //200
    self.btn_200 = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.btn_200.frame = CGRectMake(CGRectGetMaxX(self.btn_100.frame) + 15, CGRectGetMaxY(self.btn_5.frame) + 12, length_x, 45);
    self.btn_200.tag = 200;
    self.btn_200.layer.cornerRadius = 5;
    self.btn_200.layer.borderColor = [UIColor grayColor].CGColor;
    self.btn_200.layer.borderWidth = 0.5f;
    self.btn_200.backgroundColor = [UIColor whiteColor];
    [self.btn_200 setTitle:@"200元" forState:(UIControlStateNormal)];
    [self.btn_200 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    [self.scrollView addSubview:self.btn_200];
    [self.btn_200 addTarget:self action:@selector(btn_tixian:) forControlEvents:(UIControlEventTouchUpInside)];
    
    
    //500
    self.btn_500 = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.btn_500.frame = CGRectMake(15 , CGRectGetMaxY(self.btn_50.frame) + 12, length_x, 45);
    self.btn_500.tag = 500;
    self.btn_500.layer.cornerRadius = 5;
    self.btn_500.layer.borderColor = [UIColor grayColor].CGColor;
    self.btn_500.layer.borderWidth = 0.5f;
    self.btn_500.backgroundColor = [UIColor whiteColor];
    [self.btn_500 setTitle:@"500元" forState:(UIControlStateNormal)];
    [self.btn_500 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    [self.scrollView addSubview:self.btn_500];
    [self.btn_500 addTarget:self action:@selector(btn_tixian:) forControlEvents:(UIControlEventTouchUpInside)];
    
    
    //1000
    self.btn_1000 = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.btn_1000.frame = CGRectMake(CGRectGetMaxX(self.btn_500.frame) + 15, CGRectGetMaxY(self.btn_50.frame) + 12, length_x, 45);
    self.btn_1000.tag = 1000;
    self.btn_1000.layer.cornerRadius = 5;
    self.btn_1000.layer.borderColor = [UIColor grayColor].CGColor;
    self.btn_1000.layer.borderWidth = 0.5f;
    self.btn_1000.backgroundColor = [UIColor whiteColor];
    [self.btn_1000 setTitle:@"1000元" forState:(UIControlStateNormal)];
    [self.btn_1000 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    [self.scrollView addSubview:self.btn_1000];
    [self.btn_1000 addTarget:self action:@selector(btn_tixian:) forControlEvents:(UIControlEventTouchUpInside)];
    
    
    self.lbl_yue = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 10 - 300, CGRectGetMaxY(self.btn_500.frame) + 10, 300, 15)];
    self.lbl_yue.textAlignment = NSTextAlignmentRight;
    self.lbl_yue.text = @"可提现余额:100.0元";
    self.lbl_yue.font = [UIFont systemFontOfSize:13];
    [self.scrollView addSubview:self.lbl_yue];
    
    //点击提现
    UIButton * btn_tixian = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_tixian.frame = CGRectMake(15, CGRectGetMaxY(self.btn_500.frame) + 60, SCREEN_WIDTH - 30, 45);
    btn_tixian.backgroundColor = navi_bar_bg_color;
    btn_tixian.layer.cornerRadius = 5;
    [btn_tixian setTitle:@"立即提现" forState:(UIControlStateNormal)];
    [btn_tixian setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    btn_tixian.titleLabel.font = [UIFont systemFontOfSize:17];
    [self.scrollView addSubview:btn_tixian];
    
    [btn_tixian addTarget:self action:@selector(btn_tixianAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

#pragma mark - 点击提现
- (void )btn_tixianAction:(UIButton *)sender
{
    [self.text_userName resignFirstResponder];
    [self.text_zhifubao resignFirstResponder];
    
    NSLog(@"点击提现");
}

#pragma mark - 提现
- (void )btn_tixian:(UIButton *)sender
{
    [self.text_userName resignFirstResponder];
    [self.text_zhifubao resignFirstResponder];
    
//    NSLog(@"提现多少钱");
    
    self.btn_5.backgroundColor = [UIColor whiteColor];
    [self.btn_5 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    self.btn_10.backgroundColor = [UIColor whiteColor];
    [self.btn_10 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    self.btn_20.backgroundColor = [UIColor whiteColor];
    [self.btn_20 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    self.btn_50.backgroundColor = [UIColor whiteColor];
    [self.btn_50 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    self.btn_100.backgroundColor = [UIColor whiteColor];
    [self.btn_100 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    self.btn_200.backgroundColor = [UIColor whiteColor];
    [self.btn_200 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    self.btn_500.backgroundColor = [UIColor whiteColor];
    [self.btn_500 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    self.btn_1000.backgroundColor = [UIColor whiteColor];
    [self.btn_1000 setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    
    
    if([sender.backgroundColor isEqual:[UIColor whiteColor]])
    {
        sender.backgroundColor = navi_bar_bg_color;
        [sender setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    }
}

#pragma mark - textfiled代理
- (BOOL )textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    
    [UIView animateWithDuration:0.7 animations:^{
        
        self.scrollView.contentOffset = CGPointMake(0, 0);
        
    } completion:^(BOOL finished) {
        
    }];
    
    return YES;
}

#pragma mark - scrollView代理
- (void )scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    [self.text_userName resignFirstResponder];
    [self.text_zhifubao resignFirstResponder];
}









@end
